﻿<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>会员消费明细</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/qmsk-1.2.js"></script>
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<link href="../css/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/shopSelecterNew.js"></script>
<script type="text/javascript" src="../js/pagination.js"></script>
<script type="text/javascript" src="../js/dataTable.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script>
<script type="text/javascript" src="../js/doubleDate2.0.js"></script> 
<script type="text/javascript" src="../js/find.js"></script>
<script type="text/javascript" src="../js/commonSelecter.js"></script>
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script type="text/javascript" >
/**
 * 入口，和服务器的通信从此开始
 */
$(function() {
	refreshInput($(".serWrapper"));
	initShopSelecter();
	$('.doubledate').kuiDate({
		className : 'doubledate',
		isDisabled : "0" // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});
	$('.doubledate1').kuiDate({
		className : 'doubledate1',
		isDisabled : "0" // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});
	 $('#dtPaidStart').val(getToday());
	 $('#dtPaidEnd').val(getToday());
});


/**
 * 为查找做准备，这里主要是生成查询条件对象
 */
function toSearch() {
	$("#membercsmdt").empty();
	$("#sum").empty();
	var shopId = $('#shopID').val();
	var dtPaidStart = $('#dtPaidStart').val();
	var dtPaidEnd = $('#dtPaidEnd').val();
	var memberCardNo=$("#memberCardNo").val();
	var billNo=$("#billNo").val();
	if(IsEmpty(shopId)){
		shopId = "";
	}

	new Pagination({
		url : '../incomeDetail/find/membercsmDt',
		data : {
			shopId : shopId,
			dtPaidStart : dtPaidStart,
			dtPaidEnd : dtPaidEnd,
			memberCardNo :memberCardNo,
			billNo:billNo
		},
		success : printDataToPage,
		pageSize : 10
	});
	
	findGoodsTypeSum();
}

function printDataToPage(message) {
	var oldBillNo = null;
	dataTable({
		tbodyId : 'membercsmdt',
		heads : ["ReciveDate","SaleBillNo","GoodsName", "roomNo","MemberCardNo", "CustomerName", "LevelName", "CashAmt", "BankAmt","DepositAmt", "CashCouponAmt","couponAmt","VoucherAmt", "WipeZeroAmt", "FreeAmt","FactAmt"],
		rst : message,
		sup : {
			id : "sup",
			template : "共 [index] 条"
		}
	});
}

/**
 * 累计消费总和
 */
function findGoodsTypeSum() {
	var shopId = $('#shopID').val();
	var dtPaidStart = $('#dtPaidStart').val();
	var dtPaidEnd = $('#dtPaidEnd').val();
	var memberCardNo=$("#memberCardNo").val();
	var billNo=$("#billNo").val();
	var mp=$("#mp").val();
	if(IsEmpty(shopId)){
		shopId = "";
	}

	var rst = _findInfo("../incomeDetail/find/membercsmDt/sum", {
		"shopId" : shopId,
		"dtPaidStart" : dtPaidStart,
		"dtPaidEnd" : dtPaidEnd,
		memberCardNo :memberCardNo,
		billNo:billNo
	});

	if (IsNotEmpty(rst)) {
		var htmlStr = "合计:";
		var htmlGD = "&nbsp&nbsp&nbsp";
		var sum = 0;
		var oldsum = 0;

		var factAmt = getHtmlInt(getHeadIndexValue(0, rst, 'FactAmt'));
		if (factAmt > 0) {
			sum = sum + factAmt;
			htmlStr += "实收款:" + factAmt;
			oldsum = sum;
		}

		var payCredit = getHtmlInt(getHeadIndexValue(0, rst, 'WipeZeroAmt'));
		if (payCredit > 0) {
			sum = sum + payCredit;
			if (oldsum < sum && oldsum != 0) {
				htmlStr += htmlGD;
			}
			htmlStr += "挂账:" + payCredit;
			oldsum = sum;
		}

		var payDepstAmt = getHtmlInt(getHeadIndexValue(0, rst, 'DepositAmt'));
		if (payDepstAmt > 0) {
			sum = sum + payDepstAmt;
			if (oldsum < sum && oldsum != 0) {
				htmlStr += htmlGD;
			}
			htmlStr += "储值支付:" + payDepstAmt;
			oldsum = sum;
		}

		var payCash = getHtmlInt(getHeadIndexValue(0, rst, 'CashAmt'));
		if (payCash > 0) {
			sum = sum + payCash;
			if (oldsum < sum && oldsum != 0) {
				htmlStr += htmlGD;
			}
			htmlStr += "现金支付:" + payCash;
			oldsum = sum;
		}
		var payDisctCoup = getHtmlInt(getHeadIndexValue(0, rst, 'couponAmt'));
		if (payDisctCoup > 0) {
			sum = sum + payDisctCoup;
			if (oldsum < sum && oldsum != 0) {
				htmlStr += htmlGD;
			}
			htmlStr += "优惠券支付:" + payDisctCoup;
			oldsum = sum;
		}
		var payCashCoupAmtMny = getHtmlInt(getHeadIndexValue(0, rst, 'CashCouponAmt'));
		if (payCashCoupAmtMny > 0) {
			sum = sum + payCashCoupAmtMny;
			if (oldsum < sum && oldsum != 0) {
				htmlStr += htmlGD;
			}
			htmlStr += "代金券支付:" + payCashCoupAmtMny;
			oldsum = sum;
		}

		var FreeAmt = getHtmlInt(getHeadIndexValue(0, rst, 'FreeAmt'));
		if (FreeAmt > 0) {
			sum = sum + FreeAmt;
			if (oldsum < sum && oldsum != 0) {
				htmlStr += htmlGD;
			}
			htmlStr += "免单:" + FreeAmt;
			oldsum = sum;
		}

		var payPos = getHtmlInt(getHeadIndexValue(0, rst, 'BankAmt'));
		if (payPos > 0) {
			sum = sum + payPos;
			if (oldsum < sum && oldsum != 0) {
				htmlStr += htmlGD;
			}
			htmlStr += "POS支付:" + payPos;
			oldsum = sum;
		}

		var VoucherAmt = getHtmlInt(getHeadIndexValue(0, rst, 'VoucherAmt'));
		if (VoucherAmt > 0) {
			sum = sum + VoucherAmt;
			if (oldsum < sum && oldsum != 0) {
				htmlStr += htmlGD;
			}
			htmlStr += "抵扣券支付:" + VoucherAmt;
			oldsum = sum;
		}
		if (sum > 0) {
			$("#sum").html(htmlStr);
		} else {
			$("#sum").html("");
		}
	}
}

/**
 * 初始化店面选择器
 */
function initShopSelecter() {
	refreshInput($(".serWrapper"));
	$("#shopID").attr("disabled", "disabled");

	$("#shopIsChoosed").bind("click", function() {
		var checked = $(this).attr("checked");
		if (checked) {
			$("#shopID").removeAttr("disabled");
		} else {
			$("#shopID").attr("disabled", "disabled");
			$("#shopID").empty();
		}
	});
}

function downRescouse() {
	var shopId = $('#shopID').val();
	var dtPaidStart = $('#dtPaidStart').val();
	var dtPaidEnd = $('#dtPaidEnd').val();
	var memberCardNo=$("#memberCardNo").val();
	var billNo=$("#billNo").val();
	var mp=$("#mp").val();
	if(IsEmpty(shopId)){
		shopId = "";
	}
	var param = {
		shopId : shopId,
		dtPaidStart : dtPaidStart,
		dtPaidEnd : dtPaidEnd,
		memberCardNo :memberCardNo,
		billNo:billNo
	};
	var params = $.param(param);
	window.location.href = '../incomeDetail/membercsm/export/csv?' + $.param(param);

}

</script>
</head>
<body>
<div class="container" id="container">
  <div class="container_R fr">
    <div class="place">会员消费明细</div>
    <div class="member_search">
      <p><span><input type="checkbox" id="shopIsChoosed" style="width:auto;height:auto;border:none;">店面：</span>
 		<select id="shopID"  class="shopName" onclick="openShopListPanel(this)" style="height: 20px;"></select>
        <span>起始日期：</span>
        <input type="text" readonly class="doubledate ipticon"  id="dtPaidStart"/>
        <span>截止时间：</span>
        <input type="text" readonly class="doubledate1 ipticon" id="dtPaidEnd"/>
      </p>
      <p>
      	<span>单据号：</span><input type="text" id="billNo" class="absoluteTxt" >
      
      	<span>会员卡号：</span><input type="text" id="memberCardNo"  class="absoluteTxt">
          	<input type="button" value="查询" class="btn" onclick="toSearch()">
      </p>
      </p>
    </div>
    <table width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList">
      <caption>
      <strong>会员消费明细列表 <span id="sup">共0条</span></strong> <a href="javascript:void(0)" onclick="downRescouse()">导出数据</a>
      </caption>
      <thead>
        <tr>
          <th>日期</th>
          <th>单号</th>
          <th>项目</th>
          <th>会员卡号</th>
          <th>会员姓名</th>
          <th>会员级别</th>
          <th>现金</th>
          <th>pos</th>
          <th>储值抵扣</th>
          <th>代金券抵扣</th>
          <th>消费券</th>
          <th>抵扣券</th>
          <th>挂账</th>
          <th>免单</th>
          <th>实收</th>
        </tr>
      </thead>
      <tbody id="membercsmdt">
      
      </tbody>
    </table>
     <div id="NoResult"  class="Nothing" style="text-align:center;display: none;">无符合条件的数据！</div>
    <div id="sum" style="float: left;"></div>
    <br>
    <div id="pager" class="pager"></div>
  </div>
  <div class="fc"></div>
</div>
<!-- InstanceEndEditable --> 
<script type="text/javascript" src="../js/header.js"></script> 
<script type="text/javascript" src="../js/left.js"></script> 
<script type="text/javascript" src="../js/footer.js"></script> 
<script type="text/javascript">
clearThis("absoluteTxt");
</script>
</body>
<!-- InstanceEnd -->
</html>
